import type { StepStandardModel } from './models';

import { requestClient } from '#/api/request';

/**
 * 获取工艺标准数据集合
 * @param stepId 工艺步骤 Id
 * @param stepTaskId 工步 Id，默认为 0，表示不关联工步
 * @returns 返回查询结果
 */
export async function getStepStandardListApi(
  stepId: number,
  stepTaskId: number = 0,
) {
  return requestClient.get<StepStandardModel[]>(
    '/mes/process/stepStandard/list',
    {
      params: { stepId, stepTaskId },
    },
  );
}

/**
 * 创建工艺标准
 * @param data 要创建的工艺标准
 * @returns 返回结果
 */
export async function createStepStandardApi(data: any) {
  return requestClient.post<boolean>('/mes/process/stepStandard', data);
}

/**
 * 更新工艺标准
 * @param id 工艺标准 Id
 * @param data 要更新的工艺标准
 * @returns 返回结果
 */
export async function updateStepStandardApi(id: number, data: any) {
  return requestClient.put<boolean>(`/mes/process/stepStandard/${id}`, data);
}

/**
 * 删除工艺标准
 * @param id 工艺标准 Id
 * @returns 返回结果
 */
export async function deleteStepStandardApi(id: number) {
  return requestClient.delete<boolean>(`/mes/process/stepStandard/${id}`);
}
